#include "FileBlock.h"

QDataStream& operator>>(QDataStream &in, FileHeader &header)
{
    in >> header.fileName
       >> header.fileSize;
    return in;
}

QDataStream& operator<<(QDataStream &out, FileHeader &header)
{
    out << header.fileName
        << header.fileSize;
    return out;
}


QByteArray FileHeader::toByteArray()
{
    QByteArray message;
    QDataStream out(&message, QIODevice::WriteOnly);
    out.setVersion(QDataStream::Qt_5_12);
    out << *this;
    return message;
}

FileHeader FileHeader::fromByteArray(QByteArray &array)
{
    FileHeader header;
    QDataStream in(&array, QIODevice::ReadOnly);
    in >> header;
    return header;
}
